<% avatar_for_object = eval("#{@avatar_for}.find(#{@avatar_for_id})") -%>
<h1>Upload <%= @avatar_for -%> Picture: <%= link_to avatar_for_object.name, url_for(avatar_for_object) -%></h1>

<%= error_messages_for :avatar -%>

<% form_tag({:action => :create}, :multipart => true) do %>

  <%= hidden_field_tag(:owner_type, @avatar_for ) -%>
  <%= hidden_field_tag(:owner_id, @avatar_for_id ) -%>
  <%= hidden_field_tag(:return_to, params[:return_to] ? params[:return_to] : eval("#{@avatar_for.downcase}_avatars_path(#{@avatar_for_id})")) -%>
  <br/>
	<p>
    <center>
      <b>Picture file: </b>
	  <%= file_field 'avatar', 'image_file' %>
	</center>
  </p>
	
  <br/>
  
  <p>
  	<center>
      <%= submit_tag "Upload", :disable_with => "Uploading..." %>
	    or <%= link_to "Cancel", params[:return_to] ? params[:return_to] : eval("#{@avatar_for.downcase}_avatars_path(#{@avatar_for_id})") -%>
	</center>
  </p>
<% end %>